package cn.yr.clock.controller;

import cn.yr.clock.domain.entity.EnginePrizeRel;
import cn.yr.clock.domain.vo.PageVo;
import cn.yr.clock.service.EnginePrizeRelService;
import cn.yr.common.exception.ret.Ret;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;



/**
 * 
 * @author Lang
 * @email 1102076808@qq.com
 * @date 2021-09-26 20:16:58
 */
@RestController
@RequestMapping("/enginePrizeRel")
public class EnginePrizeRelController{
    @Autowired
    private EnginePrizeRelService enginePrizeRelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Ret list(@RequestBody PageVo<EnginePrizeRel> pageVo){
    	PageVo<EnginePrizeRel> pageEnginePrizeRel = enginePrizeRelService.page(pageVo,new QueryWrapper<>());
        return Ret.success(pageEnginePrizeRel);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{enginePrizeId}")
    public Ret info(@PathVariable("enginePrizeId") Long enginePrizeId){
		EnginePrizeRel  enginePrizeRel = enginePrizeRelService.getById(enginePrizeId);
	    return Ret.success(enginePrizeRel);
    }

    /**
     * 保存
     */
    @RequestMapping("/add")
    public Ret save(@Validated @RequestBody EnginePrizeRel enginePrizeRel){
		enginePrizeRelService.save(enginePrizeRel);
	    return Ret.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/edit")
    public Ret update(@Validated @RequestBody EnginePrizeRel enginePrizeRel){
		enginePrizeRelService.updateById(enginePrizeRel);
	    return Ret.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/remove")
    public Ret delete(@RequestBody Long[] enginePrizeIds){
		enginePrizeRelService.removeByIds(Arrays.asList(enginePrizeIds));
        return Ret.success();
    }

}
